package collection;

import java.util.ArrayList;
import java.util.Collection;

//集合间的操作
public class CollectionOperDemo {
    public static void main(String[] args) {
        Collection c1 = new ArrayList();
        Collection c2 = new ArrayList();

        c1.add("java");
        c1.add("c++");
        c1.add("php");

        c2.add("python");
        c2.add("android");
        c2.add("ios");

        c1.addAll(c2);

        System.out.println("c1:"+c1);
        System.out.println("c2:"+c2);

        Collection c3 = new ArrayList();

        c3.add("java");
        c3.add("c++");
        c3.add("php");
        System.out.println("c3:"+c3);

        System.out.println(c1.containsAll(c3));

        //取交集
        c1.retainAll(c3);
        c2.retainAll(c3);
        System.out.println("c1,c2与c3取共有元素");
        System.out.println("c1:"+c1);
        System.out.println("c2:"+c2);
        System.out.println("c3:"+c3);

        //删交集
        c1.removeAll(c3);
        System.out.println("c1:"+c1);
        System.out.println("c3:"+c3);

    }
}
